
********************************************************************************
**** CONVERT ISSDIRECTORS INTO A PANEL DATA WITH YEAR-DIRECTOR-FIRM OBSERVATIONS
********************************************************************************

cd "`c(pwd)'"   // Set working directory to wherever the user placed "replication_package"

* Define global paths relative to the main directory
global main_dir "`c(pwd)'"
global data_dir "$main_dir/data_analysis"
global rawdata_dir "$main_dir/data_raw"
global tables_dir "$main_dir/tables"

cd "$rawdata_dir/"
use iss_directors, clear
gen cusip6=substr(cusip,1,6)
tostring year, replace
destring year, replace
tostring company_id, replace
destring company_id, replace
drop if cusip==""
drop if cusip=="000000000"
sort cusip6 year
append using iss_directors_legacy2, force
joinby cusip6 year using CRSP_Hist_Cusips, unmatched(master)
rename _merge _merge_crsp
tab _merge_crsp
joinby permno year using compustat_permno_gvkey, unmatched(master)
rename _merge _merge_gvkey
tab _merge_gvkey
drop if director_detail_id==.
drop if gvkey==.
* director_detail_id==35025 has WAY TOO MANY seats: 53 seats per year
drop if director_detail_id==35025
keep year director_detail_id gvkey
rename director_detail_id directorid
cd "$data_dir/"
save iss_empl, replace

